{% extends 'base.html' %}
{% block content %}

<a href="/forum/">Forums</a> <b>></b> {{forum.title}}

{% if forum.getThreads %}
    <table border = 1>
    {% for thread in forum.getThreads %}
    <tr>
    <td width = 200>
    {% if thread.sticky %}
    <img src="{{ PATH }}/media/sticky.png" alt="Thread Stickied" width="20" height="20"/>
    {% endif %}
    {% if thread.locked %}
    <img src="{{ PATH }}/media/lock.png" alt="Thread Locked" width="20" height="20"/>
    {% endif %}
    <a href="/forum/{{ forum.id }}/{{ thread.id }}">{{ thread.title }}</a></td>
    <td width = 60>Posts: {{ thread.getForumPosts.count }}</td>
        {% if user.is_staff %}
        <td> <form action="" method="post">
        {% csrf_token %}
        <input type="submit" name="delete_thread" value="Delete" />
        {% if thread.sticky %}
        <input type="submit" name="unsticky_thread" value="Unsticky" />
        {% else %}
        <input type="submit" name="sticky_thread" value="Sticky" />
        {% endif %}
        {% if thread.locked %}
        <input type="submit" name="unlock_thread" value="Unlock" />
        {% else %}
        <input type="submit" name="lock_thread" value="Lock" />
        {% endif %}
        <input type="hidden" name="thread" value= {{ thread.id }} />
        </form> </td>
        {% endif %}
    </tr>
    {% endfor %}
    </table>
{% else %}
    <p>No threads in this forum</p>
{% endif %}
{% if user.is_authenticated %}
        <a href="/forum/{{ forum.id }}/new">New Thread</a>
        {% else %}
    <a href='/accounts/login/'>You must be logged in to post in the forums.</a>
    {% endif %}
{% endblock %}